<%-- 
    Document   : add
    Created on : 6-dec-2009, 15:24:19
    Author     : Simon
--%>

<%-- ${pageContext.request.contextPath} --%>
<%@include file="../../header.jsp" %>

<h1>New prescription for ${patientname}</h1>


<c:if test="${!empty flash}">
    <div class="flash error">${flash}</div>
</c:if>

<form method="post" action="${pageContext.request.contextPath}/gp/patient/prescription/saveadd.jsp">
    <table>
        <tr>
            <td>
                <label for="medication">Medication</label>
            </td>
            <td>
                <input type="text" id="medication" value="${medication.name}" disabled="true" />
                <input type="hidden" name="medicationId" value="${medication.id}" />
                <a href="${pageContext.request.contextPath}/gp/patient/prescription/medication">Change</a>
            </td>
        </tr>
        <tr>
            <td>
                <label for="dosage">Dosage</label>
            </td>
            <td>
                <input type="radio" name="dosageIsFixed" value="true" checked="true" id="fixed_dosage"/>Fixed
                <input type="radio" name="dosageIsFixed" value="false" id="variable_dosage"/>Variable
                <div id="fixed">
                    <input type="text" name="dosageDosage" size="3" id="fixed_dosage_dosage" value="${medication.stdDose}"/>
                    <select name="dosageUnit" id="dosage_unit">
                        <c:forEach var="option" items="${units}">
                            <option value="${option.unit}">${option.unit}</option>
                        </c:forEach>
                    </select>
                </div>
                <div id="variable">
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <label for="frequency">Frequency</label>
            </td>
            <td>
                <input type="text" id="frequency" name="frequency" value="${prescription.frequency}"/>
            </td>
        </tr>
        <tr>
            <td>
                <label for="start">Start time</label>
            </td>
            <td>
                <input type="text" name="startTime" id="start" />
                <input type="text" name="start_hour" id="start_hour" size="1"/>
            </td>
        </tr>
        <tr>
            <td>
                <label for="end">End time</label>
            </td>
            <td>
                <input type="text" name="endTime" id="end" />
                <input type="text" name="end_hour" id="end_hour" size="1"/>
            </td>
        </tr>
        <tr>
            <td>
                <label for="remarks">Remarks</label>
            </td>
            <td>
                <textarea name="remarks" id="remarks" value="${prescription.remarks}"></textarea>
            </td>
        </tr>
        <tr>
            <td>

            </td>
            <td>
                <input type="submit" value="Add" name="submit" />
            </td>
        </tr>
    </table>
</form>

<div class="back">
    <a href="javascript:history.back()">Back</a>
</div>

<script type="text/javascript">
    $(document).ready(function() {

        $("#fixed").hide();
        $("#variable").hide();
        if ($("#fixed_dosage_dosage").val() != "") {
            $("#dosage_unit option[value=${medication.unit}]").attr("selected","true");
        }

        $("#start").focus(function() {
            $(this).datepicker({dateFormat : 'd M yy'});
        });
        $("#end").focus(function() {
            $(this).datepicker({dateFormat : 'd M yy'});
        });
        init_input_field($("#start_hour"), "HH")
        init_input_field($("#end_hour"), "HH")
        init_input_field($("#fixed_dosage_dosage"),"value");
        fixed_dosage();
        $("input[type=radio]").change(function() {
            fixed_dosage();
        });

        $("#start").datepicker({dateFormat : 'dd/mm/yy'});
        $("#end").datepicker({dateFormat : 'dd/mm/yy'});


        function fixed_dosage() {
            if ($("#fixed_dosage").attr("checked") == true)
                $("#fixed").show();
            else
                $("#fixed").hide();
        }


    });
</script>


<%@include file="../../footer.jsp" %>
